<html>
<head>
    <title>透析助手</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.6/css/sm.min.css">
    <link rel="stylesheet" href="__PUBLIC__/css/style.css">
    <link rel="stylesheet" href="__PUBLIC__/css/5s.css">
    <link rel="stylesheet" href="__PUBLIC__/css/6m.css">
    <link rel="stylesheet" href="__PUBLIC__/css/iconfont.css">
</head>
<body>
	<div class="head head-another">
		<div class="HeadContent">
			<if condition="$pid eq ''">
			<a href="<{:U('Index/index')}>" class="backIndex"><i class="iconfont">&#xe605;</i></a>
            <else />
            <a href="javascript:;" class="back"><i class="iconfont">&#xe605;</i></a>
            </if>
			<a href="javascript:;" class="HeadTitle">用药记录</a>
		</div>
	</div>
	<div class="RecordInformation" style="padding-bottom:3rem">
		<ul class="rank_list">
        <empty name="list">
            <li style="border-bottom:0;">暂 无 记 录</li>
        <else />
            <foreach name="list" item="v">
            <li>
                <if condition="$pid eq ''">
                <a href="<{:U('edit',array('id'=>$v['id']))}>">
                <else />
                <a href="javascript:;">
                </if>
                    <div class="LeftTitle"><{$v.name}></div>
                    <div class="RightContent">
                        <span class='<{:$v["is_use"]=="1"?"CheckOn":"CheckOff"}>'><{$v.use_time}></span>
                        <empty name="pid">
                        <i class="checkbox-chose">
                            <div class="item-input">
                                <label class="label-switch">
                                    <input type="checkbox" onchange="switchCheck(this,'<{$v.id}>')" <{:$v["is_use"]=='1'?'checked': ""}> />
                                    <div class="checkbox"></div>
                                </label>
                            </div>
                        </i>
                        </empty>
                    </div>
                </a>
			</li>
            </foreach>
        </empty>
		</ul>
	</div>

    <if condition="$pid eq ''">
	<div class="BtnGroup">
		<button class="btn-submit" style="margin:0;width:92.5%;" onclick="location.href='<{:U('edit')}>'">添加用药</button>
	</div>
    </if>
<script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.5.7/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='__PUBLIC__/js/myjq.js'></script>
<script type="text/javascript">
    //无限加载
    var pageNum=1;
    var page_ajax=true;//加载开关
    $(document).ready(function(){
        $(window).scroll(function(){
            var bot = 70; //bot是底部距离的高度
            if ((bot + $(window).scrollTop()) >= ($(document).height() - $(window).height())) {
                if(page_ajax){
                    page_ajax=false;
                    pageNum++;
                    $.get('<{:U("index")}>&p='+pageNum+'&pid='+'<{$pid}>',function(res){
                        if(res){
                            if(res != 'err'){
                                var goodsStr='';
                                $.each(res,function(i,item){
                                    if('<{$pid}>' == ''){
                                        goodsStr+='<li><a href="<{:U("edit")}>&id='+item.id+'"><div class="LeftTitle">'+item.name+'</div><div class="RightContent">';
                                    }else{
                                        goodsStr+='<li><a href="javascript:void(0)"><div class="LeftTitle">'+item.name+'</div><div class="RightContent">';
                                    }
                                    if(item.is_use=='1'){
                                        goodsStr+='<span class="CheckOn">'+item.use_time+'</span><i class="checkbox-chose"><div class="item-input"><label class="label-switch"><input type="checkbox" "checked" />';
                                    }else{
                                        goodsStr+='<span class="CheckOff">'+item.use_time+'</span><i class="checkbox-chose"><div class="item-input"><label class="label-switch"><input type="checkbox" />';
                                    }
                                    if('<{$pid}>' == ''){
                                        goodsStr+='<div class="checkbox"></div></label></div></i></div></a></li>';
                                    }
                                })
                                $('.rank_list').append(goodsStr);
                                page_ajax=true;
                            }
                        }
                    },'json');
                }
            }
        });
    });
    
    //改变药品使用状态
    function switchCheck(obj,id){
        if('<{$pid}>' == ''){
            if($(obj).prop("checked")==false){
                $(obj).parents(".checkbox-chose").siblings("span").removeClass("CheckOn").addClass("CheckOff");
                $.post("<{:U('changeUse')}>",{id:id,is_use:'0'});
            }else{
                $(obj).parents(".checkbox-chose").siblings("span").removeClass("CheckOff").addClass("CheckOn");
                $.post("<{:U('changeUse')}>",{id:id,is_use:'1'});
            }
        }
    }
</script>
</body>
</html>